import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
// import app from './modules/app'
import { getDoctorCutOffTime } from 'api/userInfo'

Vue.use(Vuex)

const store = new Vuex.Store({
  // modules: {
  //   app
  // },
  // getters
  state: {
    isShowBtn: true,
    btnChlx: ''
  },
  getters: {
    getShowChlx: (state) => (chlx) => {
      if (state.isShowBtn == false) {
        return state.btnChlx.indexOf(chlx) > -1
      }
      return state.isShowBtn
    }
  },
  mutations: {
    changeState(state, data) {
      state.isShowBtn = !data.flag // true页面显示 false页面不显示
      state.btnChlx = data.chlx
    }
  },
  actions: {
    getBtnStatusAsync({ commit }) {
      getDoctorCutOffTime().then(res => {
        let data = JSON.parse(res.data)// true 超时 false 不超时

        commit('changeState', data)
      })
    }
  }
})

export default store
